<template>
	<view class="content">
		<scroll-view scroll-y class="left-aside">
			<view v-for="item in kemu" :key="item.id" class="f-item b-b" :class="{active: item.id === curKmId}" @click="tabtap(item)">
				<image :src="item.content" mode=""></image>
				<text>{{item.name}}</text>

			</view>
		</scroll-view>
		<view  class="s-list" :id="'main-list'">
			<!-- <text class="s-item">item.name</text> -->
			<view class="t-list">
				<view @click="navToList(item)" class="t-item" v-for="(item,index) in teacher" :key="item.usercode">
					<image :src="item.picture"></image>
					<text>{{item.userxm}}</text>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>

	import subjectiveCaseApi from "@/api/subjectiveCase.js"
	let _this;
	export default {
		components: {
			
		},

		data() {
			return {
				teacher: [],
				kemu:[],
				curKmId:'',
				curTeaId:'',
			}
		},
		onLoad(query) {
			_this = this
			_this.initData()
		},
		computed: {
			
		},
		methods: {
			initData() {
				subjectiveCaseApi.zgal().then(res => {
					console.log(res)
					_this.kemu = res.data.km || [];
					_this.teacher = res.data.tea|| [];
					if(_this.kemu.length>0){
						_this.curKmId = _this.kemu[0].id
					}
					if(_this.teacher.length>0){
						_this.curTeaId = _this.teacher[0].usercode
					}
					
				})
			},
			getTeacherList(id) {
				subjectiveCaseApi.l_teacher({
					id: id
				}).then(res => {
					console.log(res)
					_this.teacher = res.data || []
					if(_this.teacher.length>0){
						_this.curTeaId = _this.teacher[0].usercode
					}
				})
			},
			
			//一级分类点击 科目点击
			tabtap(item){
				console.log(item)
				_this.curKmId = item.id
				//获取教师
				_this.getTeacherList(item.type)
				
			},
			//获取试题列表
			navToList(item){
				let id = item.usercode
				uni.navigateTo({
					url: `/pages/subjectiveCase/list?id=${id}`
				})
			}
		
		}
	}
</script>

<style lang='scss'>
	page,
	.content {
		height: 100%;
		background-color: #f8f8f8;
	}

	.content {
		display: flex;
	}
	.left-aside {
		flex-shrink: 0;
		width: 200upx;
		height: 100%;
		background-color: #fff;
		
		image {
			width: 80upx;
			height: 80upx;
			border-radius: 10upx;
			right: 16upx;
		}
	}
	.f-item {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		height: 100upx;
		font-size: 28upx;
		color: $font-color-base;
		position: relative;
		&.active{
			color: $base-color;
			background: #f8f8f8;
			&:before{
				content: '';
				position: absolute;
				left: 0;
				top: 50%;
				transform: translateY(-50%);
				height: 36upx;
				width: 8upx;
				background-color: $base-color;
				border-radius: 0 4px 4px 0;
				opacity: .8;
			}
		}
	}

	.right-aside{
		flex: 1;
		overflow: hidden;
		padding-left: 20upx;
	}
	.s-item{
		display: flex;
		align-items: center;
		height: 70upx;
		padding-top: 8upx;
		font-size: 28upx;
		color: $font-color-dark;
	}
	.t-list{
		display: flex;
		flex-wrap: wrap;
		width: 100%;
		background: #fff;
		padding-top: 12upx;
		&:after{
			content: '';
			flex: 99;
			height: 0;
		}
	}
	.t-item{
		flex-shrink: 0;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		width: 176upx;
		font-size: 26upx;
		color: #666;
		padding-bottom: 20upx;
		
		image{
			width: 140upx;
			height: 140upx;
		}
	}
</style>
